<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	pageContext.setAttribute("basePath",request.getContextPath());
%>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>解冻申请</title>
	<link rel="shortcut icon" href="favicon.ico">
	<link href="${basePath }/static/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/font-awesome.min.css" rel="stylesheet"/>
	<!-- bootstrap-table 表格插件样式 -->
	<link href="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/animate.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/style.css" rel="stylesheet"/>
	<link href="${basePath }/static/ruoyi/css/ry-ui.css" rel="stylesheet"/>
</head>
<body class="gray-bg">
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="thaw-form" action="${basePath }/system/thaw/search.do" method="POST">
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>申请时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间"
									   name="beginTime" required/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime" required/>
							</li>
							<li>
								<button class="btn btn-primary btn-rounded btn-sm" type="submit"><i class="fa fa-search"></i>&nbsp;搜索</button>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
       		 <div class="col-sm-12 select-table table-striped">

				 <div class="tabs-container">
					 <ul class="nav nav-tabs">
						 <li class="active">
							 <a data-toggle="tab" href="#tab-1" aria-expanded="true">申请</a>
						 </li>
						 <li>
							 <a data-toggle="tab" href="#tab-2" aria-expanded="false">待审</a>
						 </li>
					 </ul>
					 <div class="tab-content">
						 <div id="tab-1" class="tab-pane active">
							 <div class="panel-body">
								 
								 <div class="table-responsive">
									 <table class="table table-bordered">
										 <thead>
										 <tr>
		                                     <th>
		                                        <div class="th-inner ">编号</div>
		                                     </th>
		                                     <th>
		                                        <div class="th-inner ">申请邮箱</div>
		                                     </th>
		                                     <th>
		                                        <div class="th-inner ">申请理由</div>
		                                     </th>
		                                     <th>
		                                        <div class="th-inner ">申请时间</div>
		                                     </th>
		                                     <th style="text-align: center;">
		                                        <div class="th-inner ">审核状态</div>
		                                     </th>
		                                     <th>
		                                        <div class="th-inner ">审核时间</div>
		                                     </th>
		                                     <th>
		                                        <div class="th-inner ">审核理由</div>
		                                     </th>
		                                     <th style="text-align: center;">
		                                        <div class="th-inner ">审核人</div>
		                                     </th>
										 </tr>
										 </thead>
										 <tbody>
										 <c:forEach items="${query.list }" var="thaw" varStatus="status">
										 	
										 	<tr  data-index="${thaw.applicationId }">
		                                     <td>${status.index+1 }</td>
											 <td>${thaw.email }</td>
											 <td>${thaw.content }</td>
											 <td>${thaw.applicationTime }</td>
											 <c:if test="${thaw.status == 0 }">
											 	 <td style="text-align: center;">
												 	<span class="label label-warning">待审</span>
												 </td>
												 <td>--</td>
												 <td>--</td>
												 <td style="text-align: center;">--</td>
											 </c:if>
											 
											 <c:if test="${thaw.status == 1 }">
											 	 <td style="text-align: center;">
												 	<span class="label label-info">通过</span>
												 </td>
												 <td>${thaw.checkTime }</td>
												 <td>${thaw.reason }</td>
												 <td style="text-align: center;">${thaw.auditor }</td>
											 </c:if>
											 
											 <c:if test="${thaw.status == 2 }">
											 	 <td style="text-align: center;">
												 	<span class="label label-danger">拒绝</span>
												 </td>
												 <td>${thaw.checkTime }</td>
												 <td>${thaw.reason }</td>
												 <td style="text-align: center;">${thaw.auditor }</td>
											 </c:if>
										 </tr>
										 </c:forEach>
										 </tbody>
									 </table>
								 </div>
								 
								 <div class="fixed-table-pagination" style="display: block;">
                            <div class="pull-left pagination-detail">
                                <span class="pagination-info">第${query.pageNum }页，共${query.pages + 1}页，共  ${query.total } 条记录。</span>
                            </div>
                            <div class="pull-right pagination">
                                <ul class="pagination pagination-outline">
                                    <c:choose>
									    <c:when test="${query.pageNum == 1 }"> 
									   		<li class="page-pre active">
		                                    	<a href="javascript:void(0)">‹</a>
		                                    </li>
									   	</c:when>
									   	<c:otherwise>
									   		<li class="page-pre">
		                                    	<a href="${basePath }/system/thaw/list.do?pagenum=${query.pageNum - 1 }">‹</a>
		                                    </li>
									   	</c:otherwise>
									</c:choose>
                                    
                                    <c:forEach items="${query.navigateNums }" var="num">
                                    	<c:if test="${query.pageNum == num }">
                                    		<li class="page-number active">
                                    			<a href="javascript:void(0)">${num }</a>
                                    		</li>
                                    	</c:if>
                                    	<c:if test="${query.pageNum != num }">
                                    		<li class="page-number">
                                    			<a href="${basePath }/system/thaw/list.do?pagenum=${num }">${num }</a>
                                    		</li>
                                    	</c:if>
                                    </c:forEach>
                                    <c:if test="${query.pageNum == query.pages+1 }">
	                                    <li class="page-next active">
	                                    	<a href="javascript:void(0)">›</a>
	                                    </li>
                                    </c:if>
                                    <c:if test="${query.pageNum < query.pages }">
	                                    <li class="page-next">
	                                    	<a href="${basePath }/system/thaw/list.do?pagenum=${query.pageNum + 1 }">›</a>
	                                    </li>
                                    </c:if>
                                </ul>
                            </div>
                        </div>
								 
							 </div>
						 </div>
						 <div id="tab-2" class="tab-pane">
							 <div class="panel-body">

								 <div class="table-responsive">
									 <table class="table table-bordered">
										 <thead>
										 <tr>
											 <th style="width:45px;">编号</th>
											 <th>申请邮箱</th>
											 <th>申请理由</th>
											 <th>申请时间</th>
											 <th style="text-align: center;">
		                                        <div class="th-inner">操作</div>
		                                     </th>
										 </tr>
										 </thead>
										 <tbody>
											 <c:forEach items="${query.list }" var="thaw" varStatus="status">
											 	<c:if test="${thaw.status == 0 }">
												 	<tr data-index="${thaw.applicationId }">
					                                     <td style="text-align: center;">${status.index+1 }</td>
														 <td>${thaw.email }</td>
														 <td>${thaw.content }</td>
														 <td>${thaw.applicationTime }</td>
														 <td style="text-align: center;">
															 <a class="btn btn-success btn-xs thaw_pass" href="javascript:void(0)" data-id="${thaw.applicationId }">
																 <i class="fa fa-edit"></i>通过
															 </a>
															 <a class="btn btn-danger btn-xs thaw_refuse" href="javascript:void(0)" data-id="${thaw.applicationId }">
																 <i class="fa fa-edit"></i>拒绝
															 </a>
													 	</td>
												 	</tr>
											 	</c:if>
											 </c:forEach>										 
										 </tbody>
									 </table>
								 </div>

							 </div>
						 </div>
					 </div>


				 </div>


	        </div>
	    </div>
	</div>
	
	<input class="hidden user_id" value="${user.userId }"/>
	<input class="hidden user_name" value="${user.name }"/>
	
<script src="${basePath }/static/js/jquery.min.js"></script>
<script src="${basePath }/static/js/bootstrap.min.js"></script>
<!-- bootstrap-table 表格插件 -->
<script src="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${basePath }/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="${basePath }/static/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="${basePath }/static/ajax/libs/validate/messages_zh.min.js"></script>
<script src="${basePath }/static/ajax/libs/validate/jquery.validate.extend.js"></script>
<!-- jquery-validate 表单树插件 -->
<script src="${basePath }/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
<!-- jquery-export 表格导出插件 -->
<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
<!-- 遮罩层 -->
<script src="${basePath }/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="${basePath }/static/ajax/libs/iCheck/icheck.min.js"></script>
<script src="${basePath }/static/ajax/libs/layer/layer.min.js"></script>
<script src="${basePath }/static/ajax/libs/layui/layui.js"></script>
<script src="${basePath }/static/ruoyi/js/common.js?v=4.0.0"></script>
<script src="${basePath }/static/ruoyi/js/ry-ui.js?v=4.0.0"></script>
<script>
	//获取项目根目录
	function getRootPath(){
		let href = window.document.location.href;
		let pathName = window.document.location.pathname;
		let index = href.indexOf(pathName);
		let localhost = href.substring(0,index);
		let project = pathName.substring(0,(pathName.substr(1).indexOf('/'))+1);
			
		return (localhost+project);
	}
	
	let rootPath = getRootPath();

	$(".thaw_pass").click(function(){
		let applicationId = $(this).attr("data-id");
		let auditor = $(".user_name").val();
		let status = 1;
		layer.prompt({title: '输入操作理由，并确认', formType: 2}, function(reason, index){
		  layer.close(index);
		  thaw(applicationId, auditor, reason, 1);
		});
	});
	
	$(".thaw_refuse").click(function(){
		let applicationId = $(this).attr("data-id");
		let auditor = $(".user_name").val();
		layer.prompt({title: '输入操作理由，并确认', formType: 2}, function(reason, index){
		  layer.close(index);
		  thaw(applicationId, auditor, reason, 2);
		});
		
	});
	
	function thaw(applicationId, auditor, reason, status){
		$.ajax({
        	url:rootPath + "/update/thaw/application.do",
        	type:"POST",
        	data:{
        		applicationId : applicationId,
        		auditor : auditor,
        		reason : reason,
        		status : status
        	},
        	dataType : "json",
            success : function (response) {
            	$.modal.alert(response.message);
            	setTimeout(function(){
            		window.location.reload();
            	},2000);
            }                	  
        });
	}
	
	$(function() {
        validateRule();
    });

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#thaw-form").validate({
            rules: {
                beginTime: {
                    required: true
                },
                endTime: {
                    required: true
                }
            },
            messages: {
            	 beginTime: "时间非空",
                 endTime: "时间非空"
            }
        })
    }
	
</script>
</body>
</html>